#ifndef __GWCOMMON_H__
#define __GWCOMMON_H__

/**
*@file       gwcommon.h
*@brief      common definition
*
*@author     graywind
*@version    1.0.0.0
*@data       2011/12/27
*/

#ifdef __VC__
#include <assert.h>
#endif

///@brief   formal
#define PARAM_IN
#define PARAM_OUT
#define PARAM_INOUT

///@brief   global value
const static int gwInvalidIndex = -1;

///@brief   macro define
///color stuff
#define GW_ARGB(a,r,g,b) ((unsigned int)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
#define GW_RGBA(r,g,b,a) GW_ARGB(a,r,g,b)
#define GW_XRGB(r,g,b)   GW_ARGB(0xff,r,g,b)
#define GW_COLORVALUE(r,g,b,a) GW_RGBA((unsigned int)((r)*255.f),(gwUInt)((g)*255.f),(gwUInt)((b)*255.f),(gwUInt)((a)*255.f))

///bit-cal
#define BITS_TO_BYTES(x) (((x)+7)>>3)
#define BYTES_TO_BITS(x) ((x)<<3)

///memory operator
#define gw_new(type)              new type
#define gw_newArray(type,size)    new type[size]
#define gw_delete(ptr)            if(ptr != 0){delete ptr; ptr = 0;}
#define gw_deleteArray(ptr)       if(ptr != 0){delete [] ptr; ptr = 0;}

///null value
#define gwNULL                    0

///assert
#ifdef __VC__
#define gwAssert(exp)                  assert(exp)
#elif _DEBUG
#define gwAssert(exp)                  if(!(exp)) std::abort()
#else
#define gwAssert(exp)
#endif

//platform
#ifdef __WIN32__
#define ThreadLocalStorage __declspec(thread)
#elif __XBOX360__
#define ThreadLocalStorage __declspec(thread)
#elif __WII__
#define ThreadLocalStorage
#elif __PS3__
#define ThreadLocalStorage __thread
#else
#define ThreadLocalStorage __thread
#endif



#endif
